"""
@title(TenX腾晓2024年11月考核答题文件)
@warning(请勿修改参数和返回值)
@warning(请认真填写__init__中的数据)
@author(1323230180)
"""
from typing import List, Tuple


class TenXClass:
    def __init__(self):
        self.name = "蔡坚炯"
        self.id = "3124002004"

    @staticmethod
    def question1(n: int) -> list[str]:
        print(n)  # 打印，防止IDE警告
        list = []
        for i in range(1, n + 1):
            a = -1
            sum = 0
            while i != 0:
                b = i % 4
                i = i // 4
                a += 1
                sum += 10 ** a * b
            sum = str(sum)
            list.append(sum)
        return list

    @staticmethod
    def question2() -> list[tuple[int, int, int]]:
        list = []
        for x in range(15):
            y = int((100 - x * 7) / 4)
            z = int((300 + x * 3) / 4)
            if (100 - x * 7) % 4 == 0 and (300 + x * 3) % 4 == 0:
                a = (x, y, z)
                list.append(a)
        return list

    @staticmethod
    def question3(equipment: list[str], prop: list[str], material: list[str], items: list[str]) -> dict[str, list[str]]:
        print(equipment, prop, material, items)  # 打印，防止IDE警告
        dir = {
            "equipment": [],
            "prop": [],
            "material": []
        }

        for i in items:
            if i in equipment:
                dir["equipment"].append(i)
            elif i in prop:
                dir["prop"].append(i)
            else:
                dir["material"].append(i)
        return dir

    @staticmethod
    def question4(item_values: dict[str, int], items: list[str]) -> tuple[list[str], int]:
        print(item_values, items)  # 打印，防止IDE警告
        n = len(items)
        for i in range(n):
            for j in range(0, n - i - 1):
                if item_values[items[j]] > item_values[items[j + 1]]:
                    items[j], items[j + 1] = items[j + 1], items[j]
        list = items[-3:]
        sum = item_values[list[0]] + item_values[list[1]] + item_values[list[2]]
        Tuple = (list, sum)
        return Tuple

    @staticmethod
    def question5(matrix: list[list[int]]) -> list[tuple[int, int]]:
        print(matrix)  # 打印，防止IDE警告
        x = 0
        list = []
        for list1 in matrix:
            x += 1
            n = len(list1)
            for y in range(n):
                if list1[y] == 0:
                    loca = (x, y + 1)
                    list.append(loca)
        return list


